what is difference between Array and ArrayList?
1426
25-Aug-2017
i have more confusion in Array and ArrayList. please help with example
Niraj Kumar Mishra
28-Aug-2017Array:
1. Array is strongly typed. This means that an array can store only specific type of items\elements.
2. Array stores fixed number of elements. Size of an Array must be specified at the time of initialization.
3. No need to cast elements of an array while retrieving because it is strongly type and stores specific type of items only.
Declaration of Array
In above code I declared array size 2 that means we can store only 2 string values in array.
ArrayList:
1. ArrayList can store any type of items\elements.
2. ArrayList grows automatically and you don't need to specify size.
3. Items of ArrayList need to be cast to appropriate data type while retrieving.
Declaration of ArrayList
If you observe above code I haven’t mentioned any size in array list we can add all the required data there is no size limit and we will use add method to bind values to array list.